/**
 * Copyright (C) 2009 All Rights Reserved
 * @author sebastian chang
 * @brief practice
 */

#ifndef _H_AUTO_LOCK_H_
#define _H_AUTO_LOCK_H_

#include "lock.h"

namespace trident {

class auto_lock_t
{
public:

    /**
     * @brief constructor
     */
    auto_lock_t(lock_i* lock_, bool is_lock_ = true);

    /**
     * @brief destructor
     */
    ~auto_lock_t();

    /**
     * @brief waits for thread event
     * @return int
     */
    int lock();

    /**
     * @brief sets thread event
     * @return int
     */
    int unlock();

private:

    bool _is_lock;          ///< lock state
    lock_i* _lock;          ///< lock instance
};


} // namespace trident

#endif // _H_AUTO_LOCK_H_
